package com.stationbuilding.api;

import com.stationbuilding.bean.CountListBean;
import com.stationbuilding.bean.DictListBean;
import com.stationbuilding.bean.LoginResultBean;
import com.stationbuilding.bean.ProjectInfoBean;
import com.stationbuilding.bean.QuestionFlowListBean;
import com.stationbuilding.bean.SubdivisionListBean;
import com.stationbuilding.bean.ProcedureListBean;
import com.stationbuilding.bean.QuestionInfoBean;
import com.stationbuilding.bean.QuestionListBean;
import com.stationbuilding.bean.QuestionTypeListBean;
import com.stationbuilding.bean.ResultBean;
import com.stationbuilding.bean.ScoreListBean;
import com.stationbuilding.bean.UserListBean;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public interface ApiService {

    /**
     * 登录
     */
    @POST("api/login")
    Observable<LoginResultBean> login(
            @Query("username") String username,
            @Query("password") String password);

    /**
     * 获取站房信息
     */
    @GET("api/projectInfo/getProjectInfoById")
    Observable<ProjectInfoBean> getProjectInfoById(
            @Query("token") String token,
            @Query("id") String id,
            @Query("userId") String userId);

    /**
     * 获取字典表数据
     */
    @GET("api/qualitySafe/getDictListByPid")
    Observable<DictListBean> getDictListByPid(
            @Query("token") String token,
            @Query("pid") String pid);

    /**
     * 获取问题列表
     */
    @GET("api/qualitySafe/getQuestionList")
    Observable<QuestionListBean> getQuestionListByStatus(
            @Query("token") String token,
            @Query("processStatus") String processStatus,
            @Query("safeQualityFlag") int safeQualityFlag,
            @Query("initiator") String initiator);

    /**
     * 获取问题信息
     */
    @GET("api/qualitySafe/getObjectById")
    Observable<QuestionInfoBean> getQuestionInfoById(
            @Query("token") String token,
            @Query("questionId") String questionId);

    /**
     * 根据角色获取人员列表
     */
    @GET("api/getUserListByProjectIdAndRoleId")
    Observable<UserListBean> getUserListByProjectIdAndRoleId(
            @Query("token") String token,
            @Query("projectId") String projectId,
            @Query("roleId") String roleId);

    /**
     * 获取模型数据
     */
    @GET("api/flowSection/queryAllTree")
    Observable<SubdivisionListBean> getSubdivisionList(
            @Query("token") String token);

    /**
     * 获取模型数据
     */
    @GET("api/flowSection/getProcedureList")
    Observable<ProcedureListBean> getProcedureList(
            @Query("token") String token,
            @Query("ifdCode") String ifdCode);

    /**
     * 获取类型数据
     */
    @GET("api/qualitySafe/getQuestionTypeListByPid")
    Observable<QuestionTypeListBean> getQuestionTypeListByPid(
            @Query("token") String token,
            @Query("pid") String pid,
            @Query("safeQualityFlag") int safeQualityFlag);

    /**
     * 获取问题类型数据
     */
    @GET("api/qualitySafe/getAllQuestionTypeList")
    Observable<QuestionTypeListBean> getAllQuestionTypeList(
            @Query("token") String token,
            @Query("safeQualityFlag") int safeQualityFlag);

    /**
     * 保存问题信息
     *
     * @param token token信息
     * @param body  数据bean的body对象
     */
    @POST("api/qualitySafe/saveQuestion")
    Observable<ResultBean> saveQuestion(
            @Query("token") String token,
            @Body RequestBody body);

    /**
     * 更新问题信息
     *
     * @param token token信息
     * @param body  数据bean的body对象
     */
    @POST("api/qualitySafe/updateQuestion")
    Observable<ResultBean> updateQuestion(
            @Query("token") String token,
            @Body RequestBody body);


    /**
     * 文件下载 * * @param fileUrl * @return
     */
    @Streaming
    @GET
    Observable<ResponseBody> downloadPicture(@Url String fileUrl);

    /**
     * 获取状态等级统计数据
     */
    @GET("api/qualitySafe/queryCountGroupByLevel")
    Observable<CountListBean> getCountByLevel(
            @Query("token") String token,
            @Query("safeQualityFlag") int safeQualityFlag,
            @Query("dateId") String dateId);

    /**
     * 获取状态等级统计数据
     */
    @GET("api/qualitySafe/queryCountGroupByStatus")
    Observable<CountListBean> getCountByStatus(
            @Query("token") String token,
            @Query("safeQualityFlag") int safeQualityFlag,
            @Query("dateId") String dateId);

    /**
     * 获取分数统计数据
     */
    @GET("api/qualitySafe/queryScoreByDateAndFlag")
    Observable<ScoreListBean> getScore(
            @Query("token") String token,
            @Query("safeQualityFlag") int safeQualityFlag,
            @Query("dateId") String dateId);

    /**
     * 更新问题状态
     */
    @POST("api/qualitySafe/updateStatus")
    Observable<ResultBean> updateStatus(
            @Query("token") String token,
            @Query("safeQualityFlag") int safeQualityFlag);

    /**
     * 获取任务提醒数据
     */
    @GET("api/questionFlow/getQuestionFlowListByProjectIdAndUserId")
    Observable<QuestionFlowListBean> getQuestionFlowListByProjectIdAndUserId(
            @Query("token") String token,
            @Query("projectId") String projectId,
            @Query("userId") String userId);

    /**
     * 更新问题处理流程处理状态
     *
     * @param token token信息
     * @param body  数据bean的body对象
     */
    @POST("api/questionFlow/updateQuestionFlow")
    Observable<ResultBean> updateQuestionFlow(
            @Query("token") String token,
            @Body RequestBody body);
}
